# Maintainer: @naveen521kk on Github, Naveen M K <naveen521kk@gmail.com>
_pyname=setuptools-git
_realname=setuptools-git
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2
pkgrel=2
pkgdesc="Setuptools revision control system plugin for Git (mingw-w64)"
url="https://pypi.org/project/setuptools-git/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python"
        'git')
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=(
  "${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz"
  "0001-use-git-show-prefix.patch"
)
sha512sums=('c070911618b6b92c862fb0bd40f1daeaf79e2ba10389fa1e69e4c50cfdd39c8e57a612082cbc7d932f8cea12a769e13451e35e1c8fe34f170d4817fd0d44f156'
            '99d8cfe019f610a82af8ce69a83a08cb754d7ff40b55e7545aef35308486353a22a22b7057c2b39632fb59a39c396765fef0cce69149d80387657e103be8ac33')

prepare() {
  cd "${_pyname//_/-}-$pkgver"
  patch -p1 -i ${srcdir}/0001-use-git-show-prefix.patch
  cd "${srcdir}"
  rm -rf python-build-${CARCH}
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${CARCH}"
}

check(){
  cd "${srcdir}/python-build-${CARCH}/${pyname}"
  ${MINGW_PREFIX}/bin/python -m unittest || true
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build
}
